<%--
  Created by IntelliJ IDEA.
  User: ZZDZZ
  Date: 2024/6/19
  Time: 9:15
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<html>
<head>
    <title>图书列表</title>
    <style>
        table, th, td {
            border: 1px solid black;
            border-collapse: collapse;
        }
        th, td {
            padding: 5px;
            text-align: left;
        }
    </style>
</head>
<body>
<h1 align="center">图书列表</h1>
<table align="center">
    <tr>
        <th>图书ID</th>
        <th>标题</th>
        <th>作者</th>
        <th>是否可借</th>
    </tr>
    <c:forEach items="${booksList}" var="book">
        <tr>
            <td>${book.bookId}</td>
            <td>${book.title}</td>
            <td>${book.author}</td>
            <td>${book.available == 1 ? '是' : '否'}</td>
            <!-- 根据book.available的值显示不同的链接 -->
            <td>
                <c:choose>
                    <c:when test="${book.available == 1}">
                        <!-- 如果书籍可借，显示借书链接 -->
                        <a href="borrowBook?bookId=${book.bookId}">借书</a>
                    </c:when>
                    <c:otherwise>
                        <!-- 如果书籍不可借，显示不可借的文本 -->
                        不可借
                    </c:otherwise>
                </c:choose>
            </td>
        </tr>
    </c:forEach>
</table>
</body>
</html>
